package com.ducanh.doan;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesHelper {
	
	private static final String CONFIGURATION_NAME = "app_configuration";
	public static final String KEY_CONFIG_FIRST_LAUNCH = "config_first_launch";
	public static final String KEY_CONFIG_LOCALE = "locale_code";
	
	private SharedPreferences sharepref;
	
	public SharedPreferencesHelper(Context context) {
		sharepref = context.getSharedPreferences(CONFIGURATION_NAME, Context.MODE_PRIVATE);
	}
	
	public boolean isFirstLaunch() {
		return sharepref.getBoolean(KEY_CONFIG_FIRST_LAUNCH, true);
	}
	
	public void setIsFirstLaunch(boolean value) {
		sharepref.edit().putBoolean(KEY_CONFIG_FIRST_LAUNCH, value).commit();
	}
	
	public void setLocale(String localeCode) {
		sharepref.edit().putString(KEY_CONFIG_LOCALE, localeCode).commit();
	}
	
	public String getLocale() {
		return sharepref.getString(KEY_CONFIG_LOCALE, "en");
	}
}
